package com.icloud.wallet.boot.controller.app;


import com.icloud.common.core.api.CommonResult;
import com.icloud.wallet.boot.dto.QueryRedPacketDto;
import com.icloud.wallet.boot.dto.ReceiveRedPacketDto;
import com.icloud.wallet.boot.dto.SendRedPacketDto;
import com.icloud.wallet.boot.service.RedPacketReceiveService;
import com.icloud.wallet.boot.service.RedPacketService;
import com.icloud.wallet.boot.vo.AccRedPacketVo;
import com.icloud.wallet.boot.vo.ReceiveRedPacketVo;
import com.icloud.wallet.boot.vo.SendRedPacketVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "App红包接口")
@RequestMapping("/app/redPacket")
@RequiredArgsConstructor
public class AppRedPacketController {
    private final RedPacketService redPacketService;
    private final RedPacketReceiveService redPacketReceiveService;

    @ApiOperation("发红包")
    @PostMapping("/send")
    public CommonResult<SendRedPacketVo> send(@Validated @RequestBody SendRedPacketDto dto){
        return CommonResult.success(redPacketService.send(dto));
    }

    @ApiOperation("收红包")
    @PostMapping("/receive")
    public CommonResult<ReceiveRedPacketVo> receive(@Validated @RequestBody ReceiveRedPacketDto dto){
        return CommonResult.success(redPacketReceiveService.receive(dto));
    }

    @ApiOperation("查询红包记录")
    @PostMapping("/query")
    public CommonResult<AccRedPacketVo> query(@Validated @RequestBody QueryRedPacketDto dto){
        return CommonResult.success(redPacketService.query(dto));
    }
}
